//
//  ViewController.m
//  Country
//
//  Created by Justsoso on 16/3/3.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic,strong) NSArray *arr1;
@property (nonatomic,strong) NSArray *arr2;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.arr1 = [[NSArray alloc] initWithObjects:@"A1-南非",@"A2-墨西哥",
     @"B1-阿根廷",@"B2-尼日利亚",@"C1-英格兰",@"C2-美国",
     @"D1-德国",@"D2-澳大利亚",@"E1-荷兰",@"E2-丹麦",
     @"G1-巴西",@"G2-朝鲜",@"H1-西班牙",@"H2-瑞士",nil];
    
    self.arr2 = [[NSArray alloc] initWithObjects:@"SouthAfrica.png",@"Mexico.png",
     @"Argentina.png",@"Nigeria.png",@"England.png",@"USA.png",
     @"Germany.png",@"Australia.png",@"Holland.png",@"Denmark.png",                      @"Brazil.png",@"NorthKorea.png",@"Spain.png",@"Switzerland.png",nil];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.arr1.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
    }
    cell.textLabel.text = self.arr1[indexPath.row];
    cell.imageView.image = [UIImage imageNamed:self.arr2[indexPath.row]];
    
    
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSInteger row = indexPath.row;
    
    
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"新选择" message:[NSString stringWithFormat:@"你选择了%@队",self.arr1[row]] preferredStyle:UIAlertControllerStyleAlert];
    
    UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [self dismissViewControllerAnimated:YES completion:nil];
    }];
    
    [alert addAction:action];
    
    [self presentViewController:alert animated:YES completion:nil];
}

@end
